# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: Attenuation <ouyangjun1999@gmail.com>

pkgname=hexyl
pkgver=0.12.0
pkgrel=1
pkgdesc='Colored command-line hex viewer'
url='https://github.com/sharkdp/hexyl'
arch=('loong64' 'x86_64')
license=('Apache' 'MIT')
depends=('gcc-libs')
makedepends=('cargo' 'pandoc')
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('0a6d212f15e6078f0f553b8598ed96ae8e34a7ad1e7aafee2ba435111a18fbf1f265464d6e3a30bed551cc8387dc5da4f87221f10073258dcdb93c985e14b21d')
b2sums=('162b1419d609a86c278dc482abf4dfb68df37667f392bebd466f6154fda53a18b0505a2f71e0d78d871cb1537325565f35f369eddc255a5cda5166d6d13bebb8')

prepare() {
  cd ${pkgname}-${pkgver}
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  cargo build --release --frozen
  pandoc -s -f markdown -t man -o "doc/${pkgname}.1" "doc/${pkgname}.1.md"
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --frozen
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"
  install -Dm 644 LICENSE* -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "$pkgdir/usr/share/doc/${pkgname}"
  install -Dm 644 "doc/$pkgname.1" -t "$pkgdir/usr/share/man/man1"
}

# vim: ts=2 sw=2 et:
